import 'package:flutter/material.dart';

class FunctionDemo extends StatefulWidget {
  FunctionDemo({Key key}) : super(key: key);

  @override
  _FunctionDemoState createState() => _FunctionDemoState();
}

class _FunctionDemoState extends State<FunctionDemo> {
  void printInfo(String name, { String gender, int age }) {
    if (gender != null) {
      print("姓名: ${name}---性别: ${gender}---年龄: ${age}");
    } else {
      print("姓名: ${name}---性别: ${gender}---年龄: 保密");
    }
  }
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
       appBar: AppBar(
         title: Text("函数测试"),
       ),
       body: Column(
          children: [
            RaisedButton(
              child: Text("打印"),
              onPressed: () {
                printInfo('felix', age: 20, gender: 'male');
              }
            )
          ],
       )
    );
  }
}